package basic;

import java.util.LinkedList;

import stats.LeagueStats;

import misc.BasicLeagueOperations;

public class League implements BasicLeagueOperations{

	private String name = "";
	private Country country = null;
	private LeagueStats stats = null;
	
	private LinkedList<Club> clubs = null;
	private LinkedList<Round> rounds = null;
	
	public League(){
		super();
		this.name = null;
		this.country = null;
		this.clubs = null;
		this.rounds = null;
		this.stats = null;
	}

	public League(String name, Country country) {
		super();
		this.name = name;
		this.country = country;
		this.clubs = new LinkedList<Club>();
		this.rounds = new LinkedList<Round>();
		this.stats = new LeagueStats();
	}
	
	@Override
	public void addClub(Club club) {
		if (club != null)
			clubs.add(club);
	}
	@Override
	public Club createClub(String name, League league){
		if (name!= null && league!= null){
			return new Club(name, league);
		}
		else {
			System.out.println("error, not all player data is entered");
		}
		return null;
	}

	@Override
	public void removeClub(String name, League league) {
		for (int i = 0; i < clubs.size(); i++){
			if (name.equals(clubs.get(i)) && clubs.get(i).getLeague().equals(league))
				clubs.remove(i);
		}
		
	}
	
	@Override
	public void addRound(int round) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removeRound(int round) {
		// TODO Auto-generated method stub
		
	}	

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Country getCountry() {
		return country;
	}
	public void setCountry(Country country) {
		this.country = country;
	}
	public void setClubs(LinkedList<Club> clubs) {
		this.clubs = clubs;
	}
	public LinkedList<Club> getClubs() {
		return clubs;
	}
	public void setStats(LeagueStats stats) {
		this.stats = stats;
	}
	public LeagueStats getStats() {
		return stats;
	}
	public LinkedList<Round> getRounds() {
		return rounds;
	}
	public void setRounds(LinkedList<Round> rounds) {
		this.rounds = rounds;
	}
	public Club getClub(String name){
		for (int i = 0; i < clubs.size(); i++){
			if (clubs.get(i).getName().equals(name))
				return clubs.get(i);
		}
		return null;
	}
	
}
